Skip to content

Comments

fix: async transactional#147

Merged
rafilong merged 1 commit intogoogleapis:v2-stagingfrom
rafilong:fix-async-transactional
Aug 7, 2020
Merged

fix: async transactional#147
rafilong merged 1 commit intogoogleapis:v2-stagingfrom
rafilong:fix-async-transactional

Conversation

@rafilong
Copy link
Contributor

@rafilong rafilong commented Aug 7, 2020

Expected usecase of AsyncTransactional is as follows, update implementation to await wrapped function.

async def update_data_transaction():
    db = firestore.AsyncClient()
    transaction = db.transaction()
    city_ref = db.collection(u'cities').document(u'SF')

    @firestore.async_transactional
    async def update_in_transaction(transaction, city_ref):
        snapshot = await city_ref.get(transaction=transaction)
        transaction.update(city_ref, {
            u'population': snapshot.get(u'population') + 1
        })

    await update_in_transaction(transaction, city_ref)

@rafilong rafilong added this to the AsyncIO Client milestone Aug 7, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 7, 2020
@rafilong rafilong merged commit e640e66 into googleapis:v2-staging Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants